home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / qwesorcs.lha / qwe_sources / Helper / Helper.c
Text File  |  1995-10-03  |  3KB  |  196 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <exec/ports.h>
  5. #include <graphics/gfx.h>
  6. #include <exec/semaphores.h>
  7. #include <graphics/rastport.h>
  8. #include <cnet/empty.h>
  9. #include <cnet/cnet.h>
  10.  
  11. FILE    *fp;
  12.  
  13. char    level[4] = "99",
  14.         area[5][17],
  15.         command[15][5][17],
  16.         helptext[15][5][76],
  17.         line[15][5][100],
  18.         key[3],
  19.         args[10],
  20.         file[30] = "pfiles:helper/";
  21. short    i = 0,
  22.         j = 0,
  23.         x = 0,
  24.         y = 0,
  25.         maxges,
  26.         maxx,
  27.         max[6];
  28.  
  29. main(int argc,char **argv)
  30. {
  31.     PreMain(argc,argv);        /*** Let it here, dute! ***/
  32.  
  33.     SetDoing("Helper");
  34.  
  35.     /* AUSGABE DES RAHMENS */
  36.  
  37.     ReadFile("pfiles:helper/helper.ansi",0);
  38.  
  39.     /* EINLESEN DES HELPFILES */
  40.  
  41.     strcat(file,argv[2]);
  42.  
  43.     if (fp=fopen(file,"r"))
  44.     {
  45.         while (fgets(area[i],sizeof(area[0]),fp))
  46.         {
  47.             while (fgets(level,sizeof(level),fp)&&(atoi(level)<32))
  48.             {
  49.                 if (z->user1.Access>=(atoi(level)))
  50.                 {
  51.                     fgets(command[j][i],sizeof(command[0][0]),fp);
  52.                     fgets(helptext[j][i],sizeof(helptext[0][0]),fp);
  53.  
  54.                     x=73;
  55.                     do
  56.                     {
  57.                         helptext[j][i][x]=32;
  58.                         x--;
  59.                     }
  60.                     while (helptext[j][i][x]<11);
  61.                     helptext[j][i][74]=0;
  62.  
  63.                     x=13;
  64.                     do
  65.                     {
  66.                         command[j][i][x]=32;
  67.                         x--;
  68.                     }
  69.                     while (command[j][i][x]<11);
  70.                     command[j][i][14]=10;
  71.                     command[j][i][15]=0;
  72.  
  73.                     j++;
  74.                 }
  75.                 else
  76.                 {
  77.                     fgets(line[0][0],sizeof(command[0][0]),fp);
  78.                     fgets(line[0][0],sizeof(helptext[0][0]),fp);
  79.                 }
  80.             }
  81.             max[i]=j-1;
  82.             i++;
  83.             j=0;
  84.         }
  85.         maxx=(i-1);
  86.         fclose(fp);
  87.     }
  88.     else
  89.         goto hell;
  90.  
  91.  
  92.  
  93.     for(i=0;i<(maxx+1);i++)
  94.     {
  95.         PutText("cb");
  96.         sprintf(line[0][0],"%dH%s",(i*15+2),area[i]);
  97.         PutText(line[0][0]);
  98.         PutText("c3");
  99.     }
  100.  
  101.     for(i=0;i<maxx+1;i++)
  102.     {
  103.         for(j=0;j<(max[i]+1);j++)
  104.         {
  105.             sprintf(line[j][i],"%d;%dH%s",(6+j),(i*15+2),command[j][i]);
  106.             PutText(line[j][i]);
  107.         }
  108.     }
  109.  
  110.     x=0;
  111.     y=0;
  112.  
  113.     PutText("");
  114.     PutText(line[0][0]);
  115.     PutText("2H");
  116.     PutText(helptext[0][0]);
  117.  
  118.     key[0]=0;
  119.     while (key[0]!=32 && key[0]!=13)
  120.     {
  121.         key[0]=CNetGetKey();
  122. key0:
  123.         /* RAUF UND RUNTER */
  124.  
  125.         if (key[0]==27)
  126.         {
  127.             key[1]=CNetGetKey();
  128.             if (key[1]==91)
  129.             {
  130.                 key[2]=CNetGetKey();
  131.                 if (key[2]==66 && y<max[x])
  132.                 {
  133.                     PutText("");
  134.                     PutText(line[y][x]);
  135.                     y+=1;
  136.                     PutText("");
  137.                     PutText(line[y][x]);
  138.                     PutText("2H");
  139.                     PutText(helptext[y][x]);
  140.                 }
  141.                 if (key[2]==68 && x>0)
  142.                 {
  143.                     PutText("");
  144.                     PutText(line[y][x]);
  145.                     x-=1;
  146.                     if (y>max[x])
  147.                         y=max[x];
  148.                     PutText("");
  149.                     PutText(line[y][x]);
  150.                     PutText("2H");
  151.                     PutText(helptext[y][x]);
  152.                 }
  153.                 if (key[2]==65 && y>0)
  154.                 {
  155.                     PutText("");
  156.                     PutText(line[y][x]);
  157.                     y-=1;
  158.                     PutText("");
  159.                     PutText(line[y][x]);
  160.                     PutText("2H");
  161.                     PutText(helptext[y][x]);
  162.                 }
  163.                 if (key[2]==67 && x<maxx)
  164.                 {
  165.                     PutText("");
  166.                     PutText(line[y][x]);
  167.                     x+=1;
  168.                     if (y>max[x])
  169.                         y=max[x];
  170.                     PutText("");
  171.                     PutText(line[y][x]);
  172.                     PutText("2H");
  173.                     PutText(helptext[y][x]);
  174.                 }
  175.             }
  176.             else
  177.             {
  178.                 key[0]=key[1];
  179.                 goto key0;
  180.             }
  181.         }
  182.         if (key[0]==13)
  183.         {
  184.             i=16;
  185.             while (command[y][x][i]<33 || command[y][x][i]>96)
  186.                 i--;
  187.             command[y][x][(i+1)]=0;
  188.             strcpy(z->CStack,command[y][x]);
  189.         }
  190.     }
  191.  
  192.  
  193. hell:
  194.     PutText("1H pF1");
  195.     PostMain();          /*** Must be here ***/
  196. }